package com.bluefish.bltuan.util;

import java.util.Date;
import java.util.Random;

/**
 * 获取用户注册的激活码
 * @author junxue.rao
 *
 */
public class ActiveUtils {

    public static String getActiveCode() {
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < 12; i++) {
            buffer.append(getChar(new Random().nextInt(122)));
        }
        String timestamp = String.valueOf(new Date().getTime());
        buffer.append(timestamp);
        for (int i = 0; i < 12; i++) {
            buffer.append(getChar(new Random().nextInt(122)));
        }
        return buffer.toString();
    }

    private static String getChar(int nextInt) {
        if ((nextInt >= 97 && nextInt <= 122) || (nextInt >= 65 && nextInt <= 90)) {
            return String.valueOf((char) nextInt);
        } else {
            return String.valueOf(new Random().nextInt(10));
        }
    }
}
